#ifndef APPLICATION_H
#define APPLICATION_H

#include <QtCore/QCoreApplication>
#include <QtCore/QJsonObject>
#include <QtCore/QTimer>

#include <LogiLcd.h>

#include "UtorrentApi.h"

#define LOGI_LCD_MONO_MAX_LINE  (0x00000003)
#define LOGI_LCD_COLOR_MAX_LINE (0x00000006)

class LcdUtorrentApplication : public QCoreApplication
{
	Q_OBJECT

public:
	LcdUtorrentApplication(int argc, char *argv[]);
	~LcdUtorrentApplication();
	void shutdown();
	int exitCode;

private:
	LogiLcd *lcd;
	UtorrentApi *uApi;
	QTimer *timer;
	int firstLine;
	int firstLineColor;
	int max_dl_rate;
	int max_ul_rate;
	int max_dl_rate_after_0;
	int max_ul_rate_after_0;
	int button_increment_up;
	int button_increment_down;

	QJsonObject list;
	QJsonObject settings;

	void updateScreen();

	private slots:
		void buttonPressed(int button);
		void resultReceive(QString request,QJsonDocument result);
		void errorReceive(QString demande,int statusCodeV,QNetworkReply::NetworkError error,QString errorString);
		void timeout();
};

#endif // APPLICATION_H
